<?php
namespace app\admin\controller\recharge;

use app\common\controller\Backend;
use think\Controller;
use fast\Http;
use think\Config;
use app\admin\model\YOnlineorder;
use app\admin\model\YOrdergoods;

//个人自定义配置文件在extra backstage中;
class Pay extends Backend
{   

    public function _initialize($options = [])
    {   
    }
    
	/**
	 * 客户端下单
	 * @author violet
	 * @since 2017-11-27
	 */
	public function order(){
	    if (isset($_SERVER['HTTP_REFERER'])) {
	        $http_referer = $_SERVER['HTTP_REFERER'];
	    } else {
	        $ch = curl_init();
	        curl_setopt($ch, CURLOPT_REFERER, Config::get('GameDB.http').'/');
	        curl_setopt($ch, CURLOPT_HEADER,1);
	        curl_exec($ch);
	        curl_close ($ch);
	    }
	    
	    //基本信息判断 
	    $data = $_GET;
	    if(!isset($data['id'])){
	        $this->error('订单编辑丢失');
	    }
	    $obj_order = YOnlineorder::get(['orderID'=>$data['id'],'status'=>0]);
	    if(empty($obj_order)){
	        $this->error('订单丢失');
	    }
	    if(($obj_order['addtime'] + 600000) <= get_millisecond()){
	        $this->error('订单已过有效支付时间');
	    }
	    
	    //订单与商品关系表
	    $obj_goods = YOrdergoods::get(['oid'=>$obj_order['ID']]);
        if(empty($obj_goods)){
	        $this->error('商品信息丢失');
	    }
	    
	    $this->assign('order_info',$obj_order);
	    $this->assign('goods_info',$obj_goods);
	    return $this->view->fetch();
	}

	

}